package com.fuhao.springbootrabbit.config.direct;

import com.fuhao.springbootrabbit.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhang
 * @title: DirectConfig
 * @projectName springboot-rabbit
 * @description: TODO
 * @date 2019/5/2116:23
 */
@Configuration
public class DirectConfig {

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(RabbitConstant.DIRECT_EXCHANGE_NAME);
    }

    @Bean
    public Queue queue(){
        return new Queue(RabbitConstant.DIRECT_QUEUE_NAME,true,false,false);
    }

    @Bean
    public Binding binding(){
        return  BindingBuilder.bind(queue()).to(directExchange()).with(RabbitConstant.DIRECT_ROUTE_KEY_NAME);
    }
}
